package io.bdmc.modules.bss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.bdmc.modules.bss.entity.DeviceMachineDtsConfig;
import io.bdmc.modules.bss.mapper.DeviceMachineDtsConfigMapper;
import io.bdmc.modules.bss.service.IDeviceMachineDtsConfigService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ping
 * @since 2021-11-19
 */
@Service
public class DeviceMachineDtsConfigServiceImpl extends ServiceImpl<DeviceMachineDtsConfigMapper, DeviceMachineDtsConfig> implements IDeviceMachineDtsConfigService {


    @Override
    public long countByDeviceIdAndChannel(int deviceId,int channel) {
        QueryWrapper<DeviceMachineDtsConfig> w1 = new QueryWrapper<>();
        w1.eq("device_id",deviceId).eq("channel",channel);
        return count(w1);
    }

    @Override
    public DeviceMachineDtsConfig getOneByDeviceIdAndChannel(int deviceId, int channel) {
        QueryWrapper<DeviceMachineDtsConfig> w1 = new QueryWrapper<>();
        w1.eq("device_id",deviceId).eq("channel",channel).eq("channel",channel).last("limit 1");
        return getOne(w1);
    }
}
